<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="Public/home/css/shopcar.css" />
		<link rel="stylesheet" type="text/css" href="Public/home/css/common.css" />
		<script src="Public/home/js/jquery-1.7.2.min.js"></script>
		<script src="Public/home/js/shopcar.js"></script>
	</head>

	<body style="background: #F4F4F4;">
	<div id="header">
			<div id="header_inner">
				<a href="" class="main_page">美丽说首页</a>
				<ul>
					<li>
						<a href="">商家后台</a>
					</li>
					<li>
						<a href="">客户服务</a>
					</li>
					<li class="shopcart">
						<a href="">购物车</a>
					</li>
					<li class="order">
						<a href="">我的订单</a>
					</li>
					<li>
						<a href="">登录</a>
					</li>
					<li>
						<a href="">注册</a>
					</li>
				</ul>
			</div>
		</div>
		
		<div id="body">
			<div id="logo_move">
				<div class="pic"></div>
				<div class="move_len">
					<div class="len_heigh">
						<div class="only_red">
							<span>1</span>
							<p>
								购物车
							</p>
						</div>
						<div class="bothA">
							<span>2</span>
							<p>
								确认订单
							</p>
						</div>
						<div class="bothB">
							<span>3</span>
							<p>
								支付
							</p>
						</div>
						<div class="only_gray">
							<span>4</span>
							<p>
								完成
							</p>
						</div>
					</div>
				</div>
			</div>
			<div id="shop_body">
				<ul>
					<li>
						全部商品<span>(1)</span>
					</li>
					<li>
						优惠<span>(1)</span>
					</li>
					<li>
						库存紧张<span>(0)</span>
					</li>
				</ul>
				<div class="item">
					<table border="0" cellspacing="" cellpadding="">
						<tr class="line1">
							<td>
								<input type="checkbox" name="allPick" id="" value="" />
								&nbsp;全选 </td>
							<td>商品</td>
							<td>商品信息</td>
							<td>单价(元)</td>
							<td>数量</td>
							<td>小计(元) </td>
							<td>操作</td>
						</tr>
					</table>
					<form action="<?php echo U('Re/index')?>" method="post">
					<?php if(isset($_SESSION['cart'])){?>
                
					<?php foreach ($arr as $k=>$va){?>
					<div id="tt">
						<div class="line2">
							<input type="hidden" name="shop" id="shop" value="<?php echo $k?>" />
							<input type="checkbox" name="" id="" value="" />
							<label for class="dir">店铺：</label>
							<a href="" class="dir">
								<?php echo $k?>
							</a>
							<a href="" class="phone">
								联系客服
							</a>
							<div class="ns">
							
							<div class="mes_one es">
								<span class="point"></span>
								<span>领取3种优惠券, 最高省100元</span>
							</div>
							<div class="mes_two es">
								<span class="point"></span>
								<span>满21元减20</span>
							</div>
							<span class="mes_three es">优惠券</span>
							<div class="get es">
								<span>领取 </span>
								
							</div>
							<div class="pic es"></div>
							</div>
						</div>
						<?php foreach ($va as $key=>$v){?>
						<div class="line3">
							<input type="hidden" name="goods" id="od1" value="<?php echo $key?>" />
							<div class="td1 td">
								<input type="checkbox" name="cek" id="cek" value="" />
								<img src="<?php echo $v['options']['pic']?>" alt="" style="width:80px;height: 80px;"/>
								<a href="">
									<?php echo $v['name']?>
								</a>
							</div>
							<div class="td2 td">
								<p>
									颜色：<?php echo $v['options']['color']?>
								</p>
								<p>
									尺码：<?php echo $v['options']['size']?>
								</p>
							</div>
							<div class="td3 td">
								<span style="text-decoration: line-through;color: #999;"><?php echo $v['options']['marketprice']?>.00</span>
								<span><?php echo $v['price']?>.00</span>
								<span style="color: #FB5E00;font-size: 14px;">促销2.85折</span>
							</div>
							<div class="td4 td">
								<span class="box1">-</span>
								<input type="text" name="changeGold" id="" value="1" />
								<span class="box2">+</span>
							</div>
							<div class="td5 td">
								<span style="font-family: '微软雅黑';font-size: 13px;"><?php echo $v['price']?>.00</span>
							</div>
							<div class="td6 td">
								<a href="javascript:;" id="delGoods">
									删除
								</a>
							</div>
							<input type="hidden" name="sesSon" id="sesSon" value="<?php echo $key?>" />
						</div>
						
						
						<?php }?>
					</div>
					<input type="hidden" name="od2" id="od2" value="<?php echo $k?>" />
					
					<input type="hidden" name="ses" id="ses" value="<?php echo $k?>" />
					
					<?php }?>
					
               <?php }?>
					<div class="operate">
					<div class="all">
						<input type="checkbox" name="allPick" id="" value="" />
						<span>全选</span>
					</div>
					<div class="del">
						<a href="">
							删除
						</a>
						<a href="">
							清空失效商品
						</a>
					</div>
					<?php if(isset($numb)){?>
                
					<div class="total">
						共有<span><?php echo $numb?></span>件商品
					</div>
					
               <?php }?>
					<div class="total_price">
						总计：
						<span>¥</span>
						<span>0.00</span>
					</div>
					<button type="submit" id="go">
						去付款
					</button>
					<input type="hidden" name="as" id="" value="" />
					<input type="hidden" name="bs" id="" value="" />
					<input type="hidden" name="totGold" id="" value="" />
					<script>
						$(function(){
							$('form').submit(function(){
								var $len=$('input[name=cek]:checked').length;
								if($len==0){
									alert('请选择商品');
									return false;
								}
								var _this=$(this);
								var $as=[];
								var $bs=[];
								$('.spg').each(function(){
									var $a=$(this).parents('.line3').find('input[name=goods]').val();
									var $b=$(this).parents('#tt').find('input[name=shop]').val();
//									alert($a);alert($b);
									$as.push($a);
									$bs.push($b);
								})
								_this.find('input[name=as]').val($as);
								_this.find('input[name=bs]').val($bs);
								var $totGold=_this.find('.total_price span').eq(1).html();
								_this.find('input[name=totGold]').val($totGold);
								return true;
							})
						})
					</script>
				</div>
				</div>
				<script>
				//数据删除
					$(function(){
						$('#delGoods').live('click',function(){
							var $data1=$(this).parents('.line3').find('input[name=goods]').val();
							var $data2=$(this).parents('#tt').find('input[name=shop]').val();
//							alert($data1);alert($data2);
							var _this=$(this);
								$.ajax({
									type:"post",
									url:"<?php echo U('shopCar/del')?>",
									data:{data1:$data1,data2:$data2},
									success:function(data){
										if(data=1){
											_this.parents('.line3').remove();
										}else{
											_this.parents('#tt').remove();
										}
									}
								});
						})
					})
				</script>
				<script>
						$(function(){
							$('input[name=cek]').on('change',function(){
									var $numb=0;
									var $numb=$('.spg').length;
									$('.total span').html($numb+1);
									if($(this).attr('checked')=='checked'){
										$(this).addClass('spg');
										$('#go').css({'background':'#F13E3A','color':'white'});
									}else{
										$(this).removeClass('spg');
										if($(this).parents('.line3').siblings('.line3').find('input[name=cek]').attr('checked')=='checked'){
											$('#go').css({'background':'#F13E3A','color':'white'});
													
										}else{
											$('#go').css({'background':'#999999','color':'white'});
										}
									}
									var $b=0;
									$('.spg').each(function(e,v){
										var $a=$(this).parents('.line3').find('.td5 span').html();
										$a=parseInt($a);
										$b+=$a;
									});
									$('.total_price span').eq(1).html($b);
							})
							$('.box1').unbind('change').click(function(){
								var $num=$(this).next('input[name=changeGold]').val();
								var $shopprice=$(this).parents('.line3').find('.td3 span').eq(1).html();
								var $total=$num*$shopprice;
								$(this).parents('.line3').find('.td5 span').html($total);
								$totalN=$(this).parents('.line3').siblings('.line3').find('.td5 span').html();
								$total=parseInt($total);
								$totalN=parseInt($totalN);
								if($(this).parents('.line3').find('.td1 input').attr('checked')=='checked'){
									$(this).parents('#shop_body').find('.operate .total_price span').eq(1).html($total+$totalN);
								}
								if($('input[name=allPick]').attr('checked')=='checked'){
									$(this).parents('#shop_body').find('.operate .total_price span').eq(1).html($total+$totalN);
								}

								
							})
							$('.box2').unbind('change').click(function(){
								var $num=$(this).prev('input[name=changeGold]').val();
								var $shopprice=$(this).parents('.line3').find('.td3 span').eq(1).html();
								var $total=$num*$shopprice;
								$(this).parents('.line3').find('.td5 span').html($total);
								$totalN=$(this).parents('.line3').siblings('.line3').find('.td5 span').html();
								$total=parseInt($total);
								$totalN=parseInt($totalN);
								
								if($(this).parents('.line3').find('.td1 input').attr('checked')=='checked'){
									$(this).parents('#shop_body').find('.operate .total_price span').eq(1).html($total+$totalN);
								}
								if($('input[name=allPick]').attr('checked')=='checked'){
									$(this).parents('#shop_body').find('.operate .total_price span').eq(1).html($total+$totalN);
								}
								
							})
							
							//全选
							$('input[name=allPick]').change(function(){
								if($(this).attr('checked')=='checked'){
									$('input[name=cek]').attr('checked','cheked');
									$('input[name=cek]').addClass('spg');
									$('#go').css({'background':'#F13E3A','color':'white'});
									var $b=0;
									$('.spg').each(function(e,v){
										var $a=$(this).parents('.line3').find('.td5 span').html();
										$a=parseInt($a);
										$b+=$a;
									});
									$('.total_price span').eq(1).html($b);
									
								}else{
									$('input[name=cek]').removeAttr('checked','cheked');
									$('.total_price span').eq(1).html(0);
									$('#go').css({'background':'#999999','color':'white'});
								}
							})
						})
					</script>
					</form>
			</div>
			<p class="meg">
				美丽说 © 2016 Meilishuo.com,All Rights Reserved.
			</p>
			<div class="footer"></div>
		</div>
	</body>

</html>